package com.example.student.controller;

import com.example.student.pojo.Student;
import com.example.student.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-11-14
 * Time: 20:01
 */

@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    StudentService studentService;

    @GetMapping("/getAllStudentByScore")
    public List<Student> getAllStudentByScore() {
        return studentService.getAllStudentByScore();
    }
    @GetMapping("/getStudentCount")
    //按年级查出每个年级有多少学生
    public List<Integer> getStudentCount(@RequestParam Integer grade) {
        return studentService.getStudentCount(grade);
    }
    //按名字模糊查询学生所有信息
    @GetMapping("/getAllStudentByName")
    public List<Student> getAllStudentByName(@RequestParam String name) {
        return studentService.getAllStudentByName(name);
    }
}
